home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AECUR100.ARJ / POPMENU.C < prev    next >
C/C++ Source or Header  |  1990-03-08  |  2KB  |  91 lines

  1. /*------------------------------------------------------------
  2.  *
  3.  *  popmenu.c
  4.  *
  5.  *  copyright (c) 1987,88,89,90 J. Alan Eldridge
  6.  *
  7.  *  popup menus for Curses!
  8.  *
  9.  *------------------------------------------------------------
  10.  */
  11.  
  12. #include "curses.h"
  13.  
  14. #include <stdarg.h>
  15.  
  16. #define MAX_LIST_SIZE   32
  17.  
  18. static  int     high = VID_DEFSTAND,
  19.                 norm = VID_DEFNORM;
  20.  
  21. void
  22. init_popmenus(void)
  23. {
  24.     high = __DEFSTAND;
  25.     norm = __DEFNORM;
  26. }
  27.  
  28. void
  29. popmenuattr(n, h)
  30. {
  31.     if (iscolor()) {
  32.         if (n == -1)
  33.             n = __DEFNORM;
  34.         if (h == -1)
  35.             h = __DEFSTAND;
  36.         norm = n;
  37.         high = h;
  38.     }
  39. }
  40.  
  41. int
  42. scrollmenul(orgy, orgx, title, maxrows)
  43. char *title;
  44. {
  45.     char *choices[MAX_LIST_SIZE], **cpp;
  46.     va_list argp;
  47.  
  48.     cpp = choices;
  49.     va_start(argp, maxrows);
  50.     while (*cpp++ = va_arg(argp, char *))
  51.         ;
  52.     return scrollmenuv(orgy, orgx, title, maxrows, choices);
  53. }
  54.     
  55. int
  56. popmenul(orgy, orgx, title)
  57. char *title;
  58. {
  59.     char *choices[MAX_LIST_SIZE], **cpp;
  60.     va_list argp;
  61.  
  62.     cpp = choices;
  63.     va_start(argp, title);
  64.     while (*cpp++ = va_arg(argp, char *))
  65.         ;
  66.     return scrollmenuv(orgy, orgx, title, -1, choices);
  67. }
  68.     
  69. int
  70. popmenuv(orgy, orgx, title, array)
  71. char *title, **array;
  72. {
  73.     return scrollmenuv(orgy, orgx, title, -1, array);
  74. }
  75.  
  76. int
  77. scrollmenuv(orgy, orgx, title, maxrows, array)
  78. char *title, **array;
  79. {
  80.     int choice;
  81.     POPUP_MENU pm;
  82.     
  83.     if (pm_ctor(&pm, 0, orgy, orgx, title, maxrows, array, norm, high) != OK)
  84.         return -1;
  85.     
  86.     choice = pm_choose(&pm);
  87.     
  88.     pm_dtor(&pm);
  89.     return choice;
  90. }
  91.